namespace SinaFinanceBaseClassLibrary
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;

    public class AxisSysVolumn
    {
        private double bottomSpan = 0.0;
        private double columnSpan = 0.0;
        private SinaFinanceBaseClassLibrary.ColumnTypeEnum columnTypeEnum = SinaFinanceBaseClassLibrary.ColumnTypeEnum.KLine;
        private double columnWidth = 0.0;
        private int def_COULUMNSCOUNT = 0xf1;
        private int def_XAXISMARKCOUNT = 8;
        private int def_YAXISMARKCOUNT = 4;
        private double height = 0.0;
        private const int highZindex = 20;
        private double leftSpan = 0.0;
        private const int lowZindex = 10;
        private double Max = 0.0;
        private Canvas parentCanvas;
        public Point pointLeftBottom = new Point();
        public Point pointLeftTop = new Point();
        public Point pointRightBottom = new Point();
        public Point pointRightTop = new Point();
        private double rightSpan = 0.0;
        private double topSpan = 0.0;
        private List<bool> volumnFlagList = new List<bool>();
        private List<double> volumnInfoList = new List<double>();
        private double width = 0.0;
        private double xAxisUnitLen = 0.0;
        private double xColumnUnitWidth = 0.0;
        private List<string> yAxisDatalist = new List<string>();
        private double yAxisUnitLen = 0.0;

        public void InitVolumnsUnit()
        {
            IEnumerator enumerator = (IEnumerator) this.volumnInfoList.GetEnumerator();
            this.Max = 0.0;
            while (enumerator.MoveNext())
            {
                double num = Convert.ToDouble(enumerator.Current.ToString());
                if (num > this.Max)
                {
                    this.Max = num;
                }
            }
            double num2 = this.Max / ((double) this.Def_YAXISMARKCOUNT);
            this.yAxisDatalist.Clear();
            for (int i = 0; i < this.Def_YAXISMARKCOUNT; i++)
            {
                this.yAxisDatalist.Add((this.Max - (num2 * i)).ToString());
            }
        }

        public void RenderAxisSys()
        {
            this.InitVolumnsUnit();
            this.xAxisUnitLen = ((this.width - this.leftSpan) - this.rightSpan) / ((double) this.Def_XAXISMARKCOUNT);
            this.yAxisUnitLen = ((this.height - this.topSpan) - this.bottomSpan) / ((double) this.Def_YAXISMARKCOUNT);
            this.xColumnUnitWidth = ((this.width - this.leftSpan) - this.rightSpan) / ((double) this.Def_COULUMNSCOUNT);
            this.pointLeftTop = new Point(this.leftSpan, this.topSpan);
            this.pointRightTop = new Point(this.width - this.rightSpan, this.topSpan);
            this.pointRightBottom = new Point(this.width - this.rightSpan, this.height - this.bottomSpan);
            this.pointLeftBottom = new Point(this.leftSpan, this.height - this.bottomSpan);
            new AxisSysFramework { ParentCanvas = this.parentCanvas, PointLeftTop = this.pointLeftTop, PointRightTop = this.pointRightTop, PointRightBottom = this.pointRightBottom, PointLeftBottom = this.pointLeftBottom, XAxisUnitLen = this.xAxisUnitLen, YAxisUnitLen = this.yAxisUnitLen, XAxisMarkCount = this.Def_XAXISMARKCOUNT + 1, YAxisMarkCount = this.Def_YAXISMARKCOUNT, ControlZindex = 20 }.RenderAxisSysFramework();
            new AxisSysMarks { ParentCanvas = this.parentCanvas, IsSameColor = true }.DrawAxisMarks(this.leftSpan, this.topSpan, this.yAxisUnitLen, this.yAxisDatalist, XorYAxisEnum.volumnYaxis);
            IEnumerator enumerator = (IEnumerator) this.volumnInfoList.GetEnumerator();
            double num = (this.Height - this.topSpan) - this.bottomSpan;
            int num2 = 0;
            this.RenderWidth();
            while (enumerator.MoveNext())
            {
                double num3 = Convert.ToDouble(enumerator.Current.ToString());
                VolumnColumn column = new VolumnColumn {
                    ColumnWidth = this.columnWidth,
                    ColumnSpan = this.columnSpan,
                    ColumnHeight = (num * num3) / this.Max,
                    DEF_COLUMN_HEIGHT = num,
                    LeftSpan = this.leftSpan,
                    TopSpan = this.topSpan,
                    ParentCanvas = this.parentCanvas,
                    Index = num2
                };
                if ((this.volumnFlagList != null) && (this.volumnFlagList.Count > 0))
                {
                    if (this.volumnFlagList[num2])
                    {
                        column.ColumnColor = Colors.Red;
                    }
                    else
                    {
                        column.ColumnColor = Colors.Green;
                    }
                }
                column.RenderColumn(this.columnTypeEnum);
                num2++;
            }
        }

        protected void RenderWidth()
        {
            this.columnWidth = (4.0 * ((this.width - this.leftSpan) - this.rightSpan)) / ((double) ((5 * this.Def_COULUMNSCOUNT) - 1));
            this.columnSpan = this.columnWidth / 4.0;
        }

        public double BottomSpan
        {
            get
            {
                return this.bottomSpan;
            }
            set
            {
                this.bottomSpan = value;
            }
        }

        public SinaFinanceBaseClassLibrary.ColumnTypeEnum ColumnTypeEnum
        {
            get
            {
                return this.columnTypeEnum;
            }
            set
            {
                this.columnTypeEnum = value;
            }
        }

        public int Def_COULUMNSCOUNT
        {
            get
            {
                return this.def_COULUMNSCOUNT;
            }
            set
            {
                this.def_COULUMNSCOUNT = value;
            }
        }

        public int Def_XAXISMARKCOUNT
        {
            get
            {
                return this.def_XAXISMARKCOUNT;
            }
            set
            {
                this.def_XAXISMARKCOUNT = value;
            }
        }

        public int Def_YAXISMARKCOUNT
        {
            get
            {
                return this.def_YAXISMARKCOUNT;
            }
            set
            {
                this.def_YAXISMARKCOUNT = value;
            }
        }

        public double Height
        {
            get
            {
                return this.height;
            }
            set
            {
                this.height = value;
            }
        }

        public double LeftSpan
        {
            get
            {
                return this.leftSpan;
            }
            set
            {
                this.leftSpan = value;
            }
        }

        public Canvas ParentCanvas
        {
            get
            {
                return this.parentCanvas;
            }
            set
            {
                this.parentCanvas = value;
            }
        }

        public double RightSpan
        {
            get
            {
                return this.rightSpan;
            }
            set
            {
                this.rightSpan = value;
            }
        }

        public double TopSpan
        {
            get
            {
                return this.topSpan;
            }
            set
            {
                this.topSpan = value;
            }
        }

        public List<bool> VolumnFlagList
        {
            get
            {
                return this.volumnFlagList;
            }
            set
            {
                this.volumnFlagList = value;
            }
        }

        public List<double> VolumnInfoList
        {
            get
            {
                return this.volumnInfoList;
            }
            set
            {
                this.volumnInfoList = value;
            }
        }

        public double Width
        {
            get
            {
                return this.width;
            }
            set
            {
                this.width = value;
            }
        }

        public List<string> YaxisDatalist
        {
            get
            {
                return this.yAxisDatalist;
            }
            set
            {
                this.yAxisDatalist = value;
            }
        }
    }
}
